#!/bin/bash

function daemon() {
    result=$(netstat -anpl | grep $ip_port)
    if [ "$result" == "" ]; then
        echo 重启服务 $ip_port
	    python3 $script_path
    fi
}

ip_port=$1
script_path=$(dirname $(readlink -f "$0"))/startup.py
echo $script_path

while true
do
    daemon
    sleep 180
done
